<template>
  <div style="margin: auto;margin-top: -55px">
    <div style="height: 20px">
      <div style="float:left;margin-left:20px" @click="my()">
        <i style="margin-left: 0px" class="el-icon-back"></i>
      </div>
    </div>
    <div style="height: 100px">
      <h2><font color="#6495ed" size="6px" style="margin-top: 110px">美团外卖</font></h2>
    </div>
    <div>
      <div style="margin: 20px;"></div>
      <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
        <el-form-item label="用户名">
          <el-input v-model="formLabelAlign.u_name"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="formLabelAlign.u_pwd"></el-input>
        </el-form-item>
        <el-form-item label="邮箱">
          <el-input v-model="formLabelAlign.u_phone"></el-input>
        </el-form-item>
        <el-form-item label="验证码">
          <el-input v-model="formLabelAlign.u_code"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getCode()" >获取验证码</el-button>
          <el-button type="primary" @click="register()">注册</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
  import axios from 'axios'
  export default {
    data() {
      return {
        labelPosition: 'right',
        formLabelAlign: {
          u_name: '',
          u_pwd: '',
          u_phone: '',
          u_code: '',
        }
      };
    },
    methods:{
      my(){
        this.$router.push({name:"my"});
      },
      getCode(){
        axios.get("/waimai/UserController/getCode/"+this.formLabelAlign.u_phone).then(function (res) {
            if(res.data.msg=="ok"){
              alert("111发送成功");
            }else{
              alert("123发送失败");
            }
        })
      },
      register(){
        var _this = this;
        axios.post("/waimai/UserController/userRegister",this.formLabelAlign).then(function (res) {
            if(res.data.msg=="ok"){
              _this.$router.push({name:"mylogin"});
            }else {
              alert("注册失败");
            }
        })
      }
    }
  }
</script>
